jQuery(document)
		.ready(
				function() {
					jQuery("#msg").hide();
					jQuery("#searchWord").autocomplete(
							"/HealTheWord/searchword.json",
							{
								selectFirst : false,
								dataType : "json",
								parse : function(data) {
									return jQuery.map(data.words,
											function(word) {
												return {
													data : word,
													value : word.wordID,
													result : word.wordEn
												}
											});
								},
								formatItem : function(item) {
									// alert(item);
								return format(item);
							}
							});
					
					jQuery("#searbt")
							.click(
									function() {
										jQuery("#msg").show();
										jQuery
												.ajax( {
													url : "/HealTheWord/word.json?action=search&wordEn="
															+ jQuery
																	.trim(jQuery(
																			"#searchWord")
																			.val()),
													type : "GET",
													dataType : "json",
													error : function() {
														jQuery("#msg").hide();
														alert("error searching!");
													},
													success : function(data) {
														if (data) {
															// alert(data.wordEn);
													jQuery("#msg").hide();
													jQuery("#word").empty();
													jQuery("#word").append(
																	"<p><span class='wordEn'>"
																			+ data.wordEn
																			+ "</span>" +
																	"<br/><span class='phonetics'>"
																			+ data.phonetics
																			+ "</span>" + data.cns + "</p>");
													jQuery("#msg").hide();
													}
														else {
															alert("没有找到此单词");
														}
											}
												});
									});
				});

function format(word) {
	return word.wordEn;// + "<span>" + word.wordCn.substring(0,10) + "</span>";
}